﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OpenMVCRM.ViewModels;
using OpenMVCRM.DataAccess;
using OpenMVCRM.Services;
using OpenMVCRM.Entities;
namespace OpenMVCRM.Controllers
{

    public class StatesController : Controller
    {
        private IRepositary repo;
        public StatesController()
        {
            repo = new Repositary();
        }
        public ActionResult DoSomething(string param1, string param2)
        {

            return Json(new { Status = true, Message = "Succesfully saved" }, JsonRequestBehavior.AllowGet);
        }


        public ActionResult Index(string id)
        {
            int countryId = 0;
            int val;
            if (Int32.TryParse(id, out val))
                countryId = Convert.ToInt32(id);
            var states = repo.GetStates(countryId);
            return Json(states, JsonRequestBehavior.AllowGet);
        }

    }
}
